package com.example.myFirstWebmagic.dailyAirReport.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * 
 * ClassName: DailyAirQualityReportLogPK 
 * @Description: 日志的联合主键，爬虫名称+时间
 * @author xiongyao
 * @date 2017年3月3日
 */
@Embeddable
public class DailyAirQualityReportLogPK implements Serializable{

	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 爬虫名称
	 */
	
	private String spiderName;
	
	/**
	 * 爬虫时间
	 */
	@Column(nullable=false)
	private String time;

	public String getSpiderName() {
		return spiderName;
	}

	public void setSpiderName(String spiderName) {
		this.spiderName = spiderName;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	
	
	/*JPA联合主键需要重写hashCode和equals方法*/
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		final int prime = 31;
		int result = 1;
		result = prime * result + ((spiderName == null) ? 0 : spiderName.hashCode());
		result = prime * result + ((time == null) ? 0 : time.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if (this == obj)
            return true;
		if (obj == null)
            return false;
		if (getClass() != obj.getClass())
           return false;
		DailyAirQualityReportLogPK other = (DailyAirQualityReportLogPK) obj;
		if (spiderName == null) {
           if (other.spiderName != null)
               return false;
		} else if (!time.equals(other.time))
           return false;
		if (spiderName == null) {
            if (other.spiderName != null)
                return false;
        } else if (!spiderName.equals(other.spiderName))
           return false;
       return true;
	}

	public DailyAirQualityReportLogPK() {
		
	}
	
}
